<template>
    <fieldset>
        <ul>
            <li v-for="item in commentData" :key="item.id">
            <b>{{item.content}}</b>
            <button @click="delClick(item.id)">删除</button>
                
            </li>
        </ul>
    </fieldset>
</template>
<script>
import {mapActions,mapState} from "vuex"
import * as api from "@/api/comment"

    export default{
        methods:{
            ...mapActions('comment',['FETCH_COMMENT']),
            async delClick(id){
             let res = await api.delComment(id)
             console.log(res)
            //  重新获取列表
            if(res.data.state){
                this.FETCH_COMMENT()

            }
                
                
            }


        },
        computed:{
            ...mapState("comment",["commentData"])

        },
        mounted(){
            this.FETCH_COMMENT()

        }

    }



</script>

